<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hyprland安装与基本配置</title>
    <style>
        * {
            border-radius: 10px;
            padding: 5px;
        }
        body {
            font-family: Arial, sans-serif;
            background-color: #242930;
            line-height: 1.6;
            margin: 0;
            padding: 0;
        }
        .container {
            width: 80%;
            margin: auto;
            color: #fff;
            border-radius: 15px;
            padding: 40px;
            background: rgba(255, 255, 255, 0.1);
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
        }
        h1, h2, h3 {
            color: #fff;
        }
        pre {
            background-color: rgba(255, 255, 255, 0.1);
            padding: 10px;
            border-radius: 5px;
            overflow-x: auto;
        }
        img {
            max-width: 100%;
            height: auto;
        }
        code {
            /* background-color: rgba(255, 255, 255, 0.1); */
            /* color: #fff; */
            padding: 5px;
            border-radius: 3px;
        }
        .nav {
            width: 100%;
            
            /* background-color: rgba(255, 255, 255, 0.1);; */
            display: flex;
            text-align: center;
            justify-content: center;
            align-items: center;
            
        }
        .nav img {
            width: 50px;
            height: 50px;
            border-radius: 50%;
        }
        .nav a{
           text-decoration: none; 
           
        }
        .nav a:hover {
            text-decoration: underline;
        }
        body {
        background: linear-gradient(-45deg, #1e3c72, #2a5298, #242930, #0f2027);
        background-size: 400% 400%;
        animation: gradientAnimation 10s ease infinite;
    }
        /* 让背景颜色动态变换 */
    @keyframes gradientAnimation {
        0% { background-position: 0% 50%; }
        50% { background-position: 100% 50%; }
        100% { background-position: 0% 50%; }
    }
    </style>
</head>
<body>
    
<div class="nav">
    <img src="../img/acc.jpg" alt="">
    <a href="./index.html">主页</a>

</div>
<div class="container">
    <h1>Hyprland安装与基本配置</h1>
    <img src="../img/back.png" alt="wallpaper">
    
    <h2>Hyprland安装</h2>
    <p>Hyprland在官方源下就有提供：</p>
    <pre><code>dnf install hyprland</code></pre>
    <p>配置文件在<code>~/.config/hypr/hyprland.conf</code></p>

    <h2>顶部导航栏</h2>
    <p>可以使用waybar：</p>
    <pre><code>dnf install waybar</code></pre>
    <p>添加自启动：</p>
    <pre><code>exec-once = waybar</code></pre>
    
    <p>waybar的默认配置文件在<code>/etc/xdg/</code>目录下，我们把它复制到<code>~/.config/waybar</code></p>

    <h2>消息通知</h2>
    <p>这里我下载的是dunst：</p>
    <pre><code>dnf install dunst</code></pre>
    <p>添加自启动：</p>
    <pre><code>exec-once = dunst</code></pre>

    <h2>应用程序启动器</h2>
    <p>有wofi和rofi，这两个差不多，但是配置文件不一样。rofi在我的系统下没有找到配置文件(<code>config.rasi</code>)，wofi的配置文件在<code>/etc/xdg/</code>目录下(<code>config.jsonc</code>和<code>style.css</code>)。如果使用rofi，需要将配置里的wofi改成rofi，两个'-'去掉一个：</p>
    <pre><code>dnf install wofi</code></pre>
    或
    <pre><code>dnf install rofi</code></pre>

    <h2>设置壁纸</h2>
    <p>可以使用Hypr生态提供的Hyprpaper：</p>
    <pre><code>dnf install hyprpaper</code></pre>
    <p>添加自启动：</p>
    <pre><code>exec-once = hyprpaper</code></pre>
    <p>创建并编辑<code>~/.config/hypr/hyprpaper.conf</code></p>
    <pre><code>
# 预加载图片路径
preload=/path/to/img
# 设置壁纸路径
wallpaper=/path/to/img
# 在壁纸上启用文本渲染
splash=true
# 完全禁用ipc, 默认为禁用
ipc=off
    </code></pre>

    <h2>解决XWayland缩放模糊问题</h2>
    <p>首先禁用XWayland缩放：</p>
    <pre><code>
xwayland {
    force_zero_scaling = true
}
    </code></pre>
    <p>然后单独进行缩放：</p>
    <pre><code>exec-once xrdb-merge xft.dpi:144</code></pre>

    <h2>绑定媒体按键</h2>
    <p>如果没安装，请安装这三个包：<code>pavucontrol</code>、<code>pamixer</code>和<code>playerctl</code>，然后添加下列配置：</p>
    <pre><code>
bind = , XF86AudioRaiseVolume, exec, pamixer -i 5
bind = , XF86AudioLowerVolume, exec, pamixer -d 5
bind = , XF86AudioMicMute, exec, pamixer --default-source -m
bind = , XF86AudioMute, exec, pamixer -t
bind = , XF86AudioPlay, exec, playerctl play-pause
bind = , XF86AudioPause, exec, playerctl play-pause
bind = , XF86AudioNext, exec, playerctl next
bind = , XF86AudioPrev, exec, playerctl previous
    </code></pre>

    <h2>启用触摸板手势</h2>
    <p>Hyprland的手势默认是禁用的，找到<code>workspace_swipe</code>并把它设置为true。</p>

    <h2>调节亮度</h2>
    <p>通过<code>brightnessctl</code>，如果没有安装，请安装它。将下列文本写入配置文件：</p>
    <pre><code>
bind = , XF86MonBrightnessUp, exec, brightnessctl s +5%
bind = , XF86MonBrightnessDown, exec, brightnessctl s 5%-
    </code></pre>

    <h2>密码验证器</h2>
    <p>一部分UI需要使用密码验证（polkit），我之前的桌面环境是GNOME，但无法使用GNOME的polkit。可以用这个<code>mate-polkit</code>来替代：</p>
    <pre><code>dnf install mate-polkit</code></pre>
    <p>然后将配置写入：</p>
    <pre><code>exec-once = /usr/libexec/polkit-mate-authentication-agent-1</code></pre>

    <h2>睡眠和锁屏</h2>
    <p>可以下载<code>hypridle</code>，通过配合<code>loginctl</code>来使用：</p>
    <pre><code>exec-once = hypridle&loginctl</code></pre>
    <p>创建并编辑<code>~/.config/hypr/hypridle.conf</code>，并添加以下配置：</p>
    <pre><code>
general {
    lock_cmd = pidof hyprlock || hyprlock       # avoid starting multiple hyprlock instances.
    before_sleep_cmd = loginctl lock-session    # lock before suspend.
    after_sleep_cmd = hyprctl dispatch dpms on  # to avoid having to press a key twice to turn on the display.
}

listener {
    timeout = 150                                # 2.5min.
    on-timeout = brightnessctl -s set 10         # set monitor backlight to minimum, avoid 0 on OLED monitor.
    on-resume = brightnessctl -r                 # monitor backlight restore.
}

# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight.
listener {
    timeout = 150                                          # 2.5min.
    on-timeout = brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight.
    on-resume = brightnessctl -rd rgb:kbd_backlight        # turn on keyboard backlight.
}

listener {
    timeout = 300                                 # 5min
    on-timeout = loginctl lock-session            # lock screen when timeout has passed
}

listener {
    timeout = 330                                                     # 5.5min
    on-timeout = hyprctl dispatch dpms off                            # screen off when timeout has passed
    on-resume = hyprctl dispatch dpms on && brightnessctl -r          # screen on when activity is detected after timeout has fired.
}

listener {
    timeout = 1800                                # 30min
    on-timeout = systemctl suspend                # suspend pc
}
    </code></pre>

    <h2>结语</h2>
    <p>这里基本配置就差不多了，如果哪里有问题还请指出，如果有遗漏的地方，也欢迎讨论。</p>

    <h2>这是我使用的壁纸：</h2>
    <img src="../img/background.jpg" alt="wallpaper">
</div>

</body>
</html>
